const http = require('http');
const io = require('socket.io');

let httpServer = http.createServer();
httpServer.listen(8080);

// websocket监听的是http服务
let wsServer = io.listen(httpServer);
// 当有连接的时候会触发 connection
wsServer.on('connection', sock => {
	// sock.emit   发送
	// sock.on    接收
	sock.on('aaa', function(a, b, c) {
		console.log(a, b, c);
	})


	setInterval(function() {
		sock.emit('t', new Date().getTime());
	},1000);
})